You are a senior Laravel backend architect and lead API engineer.

I want you to build a production-ready backend system for a Coupons / Discounts / Cashback platform using Laravel.

Project goal:
Build a complete Laravel backend with REST API, MySQL database schema, authentication, admin management structure, and clean scalable architecture that will serve:
1. React Native mobile apps
2. Web frontend
3. Admin dashboard

Important instructions:
- Work as a professional software architect and backend engineer
- Use clean architecture and organized Laravel structure
- Code must be scalable, maintainable, and production-ready
- Use best practices in naming, validation, authorization, error handling, and API response formatting
- Do NOT generate random incomplete code
- Build the system step by step in a logical order
- Before coding, define the project structure and implementation plan
- Use English in code, class names, methods, migration names, models, controllers, routes, seeders, and comments
- Write clean code with clear separation of responsibilities
- Prefer Laravel API best practices
- The database must be well normalized
- Every API should support future mobile and web integration
- Keep Arabic and English content support in mind for entities like stores, categories, pages, banners, coupons, etc.

Tech stack requirements:
- Laravel latest stable version
- PHP 8.3+
- MySQL
- Laravel Sanctum for authentication
- RESTful API
- Form Request validation
- Eloquent ORM
- API Resources for consistent JSON responses
- Seeder and Factory support
- Pagination, filtering, sorting where needed
- Proper status fields and activation toggles
- Use migrations for all tables
- Use repository/service approach if appropriate, but keep it practical and not overengineered

Main business domain:
This platform is for coupons, discount codes, deals, stores, cashback offers, banners, notifications, static pages, favorites, referrals, and admin-controlled content.

There are 3 consumer layers that will use this backend:
1. Mobile app (React Native)
2. Website frontend
3. Admin dashboard

====================================
CORE MODULES TO BUILD
====================================

1) Authentication
- User register
- User login
- User logout
- Get current authenticated user
- Forgot password / reset password structure
- Token-based auth with Sanctum

2) Users
- User profile
- Update profile
- Preferred language
- Preferred country
- Account status
- Referral code support

3) Countries
- Country list
- Code, currency, status

4) Languages
- Language list
- RTL/LTR direction support

5) Categories
- Categories for stores/offers
- Arabic and English names
- Icon/image
- Sort order
- Status

6) Stores
- Belong to category
- Arabic and English names
- Slug
- Logo
- Cover image
- Description ar/en
- Website URL
- Affiliate URL
- Cashback enabled
- Cashback rate
- Featured flag
- Sort order
- Status

7) Coupons
- Belong to store
- Arabic and English title/description
- Code
- Type: code or deal
- Discount type: percentage / fixed / text
- Discount value
- Start date
- End date
- Usage count
- Featured flag
- Status

8) Cashback Offers
- Belong to store
- Arabic and English title/description
- Rate
- Terms ar/en
- Status

9) Cashback Transactions
- Belong to user and store
- Track click/session/order reference if needed
- Amount
- Status: pending / approved / rejected / paid
- Confirmed_at
- Paid_at

10) Favorites
- User can favorite store or coupon
- Polymorphic or practical implementation acceptable

11) Banners
- Arabic and English title
- Image
- Type: store / coupon / cashback / external
- Reference id if internal
- URL if external
- Start date
- End date
- Sort order
- Status

12) Notifications
- Arabic and English title/body
- Type
- Reference id
- Sent target / audience
- Read status support for users if needed

13) Static Pages
- FAQ
- Terms
- Privacy
- Contact / About if needed
- Arabic and English content

14) Referrals
- Referrer user
- Invited user
- Reward amount
- Status

15) Settings
- Key/value system
- General app settings
- Contact info
- Feature toggles

16) Tracking / Logs
- Coupon copy tracking
- Coupon/store click tracking
- Cashback activation tracking

====================================
DATABASE TABLES REQUIRED
====================================

At minimum create migrations, models, and relationships for:

- users
- personal_access_tokens
- admins (if separate admin table is preferred) OR admin role inside users
- countries
- languages
- categories
- stores
- coupons
- cashback_offers
- cashback_transactions
- banners
- favorites
- notifications
- notification_users (if needed)
- pages
- referrals
- settings
- coupon_clicks
- coupon_copies
- store_clicks
- cashback_activations

You may improve this schema if needed, but keep it clean and practical.

====================================
ROLE / AUTHORIZATION REQUIREMENTS
====================================

Support admin roles for dashboard management:
- super_admin
- content_manager
- marketing_manager
- support_agent

Implement a practical authorization structure so admin endpoints can later be protected properly.

====================================
API VERSIONING
====================================

Use API versioning:
- /api/v1/

====================================
PUBLIC / USER API ENDPOINTS
====================================

Build or scaffold these endpoint groups:

Auth:
- POST /api/v1/auth/register
- POST /api/v1/auth/login
- POST /api/v1/auth/logout
- GET /api/v1/auth/me
- POST /api/v1/auth/forgot-password
- POST /api/v1/auth/reset-password

Countries / Languages:
- GET /api/v1/countries
- GET /api/v1/languages

Home:
- GET /api/v1/home

Categories:
- GET /api/v1/categories
- GET /api/v1/categories/{id}/stores

Stores:
- GET /api/v1/stores
- GET /api/v1/stores/{id}
- GET /api/v1/stores/{id}/coupons
- GET /api/v1/stores/{id}/cashback

Coupons:
- GET /api/v1/coupons
- GET /api/v1/coupons/{id}
- POST /api/v1/coupons/{id}/copy
- POST /api/v1/coupons/{id}/click

Cashback:
- GET /api/v1/cashback/stores
- GET /api/v1/cashback/offers
- POST /api/v1/cashback/activate/{store_id}
- GET /api/v1/cashback/history

Favorites:
- GET /api/v1/favorites
- POST /api/v1/favorites/toggle

Notifications:
- GET /api/v1/notifications
- POST /api/v1/notifications/read/{id}

Pages:
- GET /api/v1/pages/{key}

Profile:
- GET /api/v1/profile
- PUT /api/v1/profile
- PUT /api/v1/profile/language
- PUT /api/v1/profile/country

====================================
ADMIN API ENDPOINTS
====================================

Create admin API structure for:
- POST /api/v1/admin/login
- POST /api/v1/admin/logout
- GET /api/v1/admin/dashboard/stats

CRUD management for:
- users
- categories
- stores
- coupons
- cashback offers
- banners
- pages
- notifications
- settings
- countries
- languages

Keep route groups organized and protected.

====================================
BUSINESS RULES
====================================

Implement these rules carefully:

1. Coupon copy action should increase tracking count and store log
2. Coupon/store click should be tracked for analytics and affiliate flow
3. Expired coupons should not appear as active
4. Featured items should be retrievable easily
5. Cashback activation must store a tracking record
6. Favorites require authenticated user
7. Banners should respect active date range
8. Static pages should support Arabic and English
9. Store and coupon listings should support:
   - pagination
   - filtering
   - sorting
   - search
10. APIs should return consistent JSON structure:
   - success
   - message
   - data
   - meta (for pagination when needed)

====================================
RESPONSE FORMAT STANDARDS
====================================

Use a consistent JSON response style like:

{
  "success": true,
  "message": "Data fetched successfully",
  "data": {...}
}

For paginated endpoints:

{
  "success": true,
  "message": "Data fetched successfully",
  "data": [...],
  "meta": {
    "current_page": 1,
    "last_page": 5,
    "per_page": 20,
    "total": 100
  }
}

For validation or errors:
- Return clean, frontend-friendly error format
- Use proper HTTP status codes

====================================
EXPECTED IMPLEMENTATION ORDER
====================================

Follow this exact workflow:

Phase 1: Project architecture and setup
- Explain folder structure
- Explain chosen approach
- Install required packages
- Configure Sanctum
- Configure API versioning
- Configure base API response helper if needed

Phase 2: Database design
- Produce database schema
- Create all migrations
- Define relationships clearly

Phase 3: Core auth
- User auth
- Admin auth
- Sanctum integration
- Profile endpoints

Phase 4: Master data modules
- Countries
- Languages
- Categories
- Settings
- Pages

Phase 5: Business modules
- Stores
- Coupons
- Cashback offers
- Favorites
- Banners
- Notifications
- Referrals
- Tracking tables

Phase 6: Admin APIs
- CRUD endpoints
- Stats endpoint
- Protected route groups

Phase 7: Seeders and sample data
- Seed realistic demo data for testing

Phase 8: Final cleanup
- Validation
- API Resources
- Pagination
- Search and filtering
- Code cleanup

====================================
OUTPUT REQUIREMENTS
====================================

I want you to work in a professional engineering style.

For every phase:
1. First explain what you are going to build
2. Then generate the code files step by step
3. Clearly mention file paths
4. Keep code complete and runnable
5. Do not skip required imports
6. Do not leave placeholders like "implement later"
7. If something is optional, state it clearly
8. Use production-style naming conventions

Also provide:
- artisan commands to create files
- migration order
- model relationships summary
- route summary
- testing checklist

====================================
CODING STYLE REQUIREMENTS
====================================

- Use strict, clean naming
- Keep controllers thin when possible
- Use FormRequest classes for validation
- Use Resource classes for API output
- Use service classes where logic is shared or complex
- Use enums where practical for statuses/types
- Avoid duplicated logic
- Prepare the project for future expansion

====================================
IMPORTANT FINAL INSTRUCTION
====================================

Do not start with general advice only.
Start immediately with:

1. High-level backend architecture
2. Proposed folder/file structure
3. Database schema design
4. Then begin generating the Laravel code in the correct order

Build this backend as if it will be handed to a professional development team for real implementation.